package com.flycms.module.qasystem.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import com.flycms.module.qasystem.model.Questions;

/**
 * 问题类Dao
 *
 * <br/>Copyright 2020
 * <br/>All rights reserved
 * @author 沁言訫語
 * @version 2020年2月17日
 * @Date 2020年2月17日
 */

@Repository
public interface QuestionsDao {

    int addQuestion(Questions question);
    
    int editQuestion(Questions question);
    
    int removeQuestionById(@Param("id") Long id);
    
    int increaseQuestionBrowsedNum(@Param("id") Long id, @Param("increaseNum") Integer increaseNum);
    
    List<Questions> getQuestionList(
            @Param("proposeUserId") Long proposeUserId,
            @Param("title") String title,
            @Param("status") Integer status,
            @Param("orderby") String orderby,
            @Param("order") String order,
            @Param("pageIndex") Integer pageIndex,
            @Param("pageSize") Integer pageSize);
    
    int getQuestionCount(
            @Param("proposeUserId") Long proposeUserId,
            @Param("title") String title,
            @Param("status") Integer status);
    
    List<Questions> getQuestionListForCustom(
            @Param("title") String title,
            @Param("status") Integer status,
            @Param("pageIndex") Integer pageIndex,
            @Param("pageSize") Integer pageSize);
    
    int getQuestionCountForCustom(
            @Param("title") String title,
            @Param("status") Integer status);
    
    Questions queryQuestionById(@Param("id") Long id, @Param("status") Integer status);
    
    int editQuestionVote(@Param("id") Long id,
            @Param("upCount") Integer upCount,
            @Param("downCount") Integer downCount);
    
    List<Questions> getQuestionListByIds(@Param("ids") List<Long> ids);
    
    int updateQuestionOptionCount(@Param("id") Long id,
            @Param("upCount") Integer upCount,
            @Param("downCount") Integer downCount,
            @Param("collectCount") Integer collectCount,
            @Param("commentCount") Integer commentCount);
    
    List<Questions> getHotQuestions(
            @Param("status") Integer status,
            @Param("pageIndex") Integer pageIndex,
            @Param("pageSize") Integer pageSize);
    

    Integer queryQuestionAnswerCount(@Param("id") Long id);
    
    int updateQuestionAnswerCount(@Param("answerCount") Integer answerCount, @Param("id") Long id);
    
}
